package com.adabank.controller;


import com.adabank.dao.GuKeMapper;
import com.adabank.module.GuKe;
import com.adabank.module.GuKeExample;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/api/v3")
@RequiresAuthentication
//@MapperScan({"com/adabank/dao"})
public class MyController {
    final GuKeMapper guKeMapper;

    GuKeExample guKeExample = new GuKeExample();

    MyController(GuKeMapper guKeMapper) {
        this.guKeMapper = guKeMapper;
    }


    @GetMapping("/status")
    public Controller<String> status() {
        GuKe guke = new GuKe();
        guKeMapper.insert(guke);

        return Controller.of("Successfully inserted a customer!");
    }

    @GetMapping("/customers")
    public Controller getEmployeesById() {
        List<GuKe> controllerList = guKeMapper.selectByExample(guKeExample);
        return Controller.of(controllerList);
    }

    @GetMapping("/customers/{id}")
    public Controller<GuKe> getEmployeesById(@PathVariable int id) {
        return Controller.of(guKeMapper.selectByPrimaryKey(id));
    }

}
